/**
 *
 */
package kevin.study.zephyr.internal;

import java.util.Observable;
import java.util.Observer;

import kevin.study.zephyr.domain.dao.IGenericDAO;
import kevin.study.zephyr.domain.model.view.View;
import kevin.study.zephyr.platform.Platform;

/**
 * @author Kevin.Huang
 * @date 2007-9-28
 */
public final class ViewManager implements Observer {
	/**
	 * 针对Form的DAO
	 */
	private IGenericDAO<View> viewDAO;

	private ViewManager() {
		super();
	}

	static final class ViewManagerHolder {
		private ViewManagerHolder() {
		}

		static final ViewManager SINGLETON = new ViewManager();
	}

	/**
	 * 获取DocumentManager实例
	 *
	 * @return
	 */
	public static ViewManager getDefault() {
		return ViewManagerHolder.SINGLETON;
	}

	/**
	 * @return the formDAO
	 */
	public IGenericDAO<View> getViewDAO() {
		if (viewDAO == null) {
			this.update(null, null);
		}
		return viewDAO;
	}

	public void update(Observable o, Object arg) {
		viewDAO = Platform.getDBManager().getDAO(View.class);
	}
}
